package solitaire.deck;

import solitaire.extras.*;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;

public class Card extends DrawObject {

	private static String DEFAULT_PICTURE = "pic//b1fv.gif";
	private BufferedImage _imgImage;
	
	public Card()
	{
		try
        {
            _imgImage = ImageIO.read( new File(DEFAULT_PICTURE) );
        }
        catch(IOException ex)
        {
            System.out.println("Could not find picture:" + DEFAULT_PICTURE);
            System.exit( -1 );
        }
	}

    public void setLocation( double dX, double dY )
    {
		m_dStartX = dX;
		m_dStartY = dY;
    }
	
	public void drawObject( Graphics g )
    {
        Graphics2D g2 = ( Graphics2D)g;
        g2.drawRenderedImage( _imgImage, 
        		AffineTransform.getTranslateInstance( 
        				m_dStartX - _imgImage.getWidth()/2 , 
        				m_dStartY - _imgImage.getHeight()/2 ) );
    }

    public boolean contains( Point2D point )
    {
        return point.getX() >= (m_dStartX - _imgImage.getWidth()/2) && 
        	point.getX() <= (m_dStartX + _imgImage.getWidth()/2) &&
        	point.getY() >= (m_dStartY - _imgImage.getHeight()/2) && 
            point.getY() <= (m_dStartY + _imgImage.getHeight()/2);
    }
}
